package com.example.hystrixDemo.service.collaspers.impl;/**
 * @Deacription TODO
 * @Author baohuajie
 * @Date 2020/12/13 23:18
 * @Version 1.0
 **/

import com.alibaba.fastjson.JSONObject;
import com.example.hystrixDemo.service.collaspers.QueryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

/**
 *@Deacription TODO
 *@Author baohuajie
 *@Date 2020/12/13 23:18
 *@Version 1.0
 **/
@Service
public class QueryServiceImpl implements QueryService {
    @Autowired
    private RestTemplate restTemplate;
    @Override
    public String querySingle(String id) {
//        String forObject = restTemplate.getForObject("http://HELLO-SERVICE/query/querySingle", String.class, id);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("id", id);
        Map<String, Object> reqData = new HashMap<>();
        reqData.put("param", jsonObject.toJSONString());
        String forObject = restTemplate.getForObject("http://localhost:8080/query/querySingle", String.class, reqData);
        return forObject;
    }
}
